package com.tqjc.business.interactivewithscan.core.thread;

import com.alibaba.fastjson.JSONObject;
import com.tqjc.business.interactivewithscan.consts.ExceptionEnum;
import com.tqjc.business.interactivewithscan.exception.CustomException;


import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class DevicesObject extends JSONObject {
    @Override
    public <T> T getObject(String key, Type type) {
        T t = super.getObject(key, type);
        if (t == null) {
            throw new CustomException(ExceptionEnum.THREAD_NO_START.getCode(), type.getTypeName() + "线程未启动");
        }
        return t;
    }

    @Override
    public <T> T getObject(String key, Class<T> clazz) {
        T t = super.getObject(key, clazz);
        if (t == null) {
            throw new CustomException(ExceptionEnum.THREAD_NO_START.getCode(), clazz.getTypeName() + "线程未启动");
        }
        return t;
    }

    public <T> T getObjectNull(String key, Class<T> clazz) {
        T t = super.getObject(key, clazz);
        return t;
    }
}
